﻿using LDM.Framework.ExceptionHandling;
using LDM.Sys.ServiceAPI.Model.ViewModel.Response.Login;
using Logs;
using Logs.LogCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace LDM.Sys.Service.Controllers.Base
{
    /// <summary>
    /// 测试服务
    /// </summary>
    [ApiController]
    [Route("[Controller]/[action]"), Produces("application/json")]
    public class DemoController : Controller
    {
        private readonly Session _session;
        private readonly ILog _log;
        public DemoController(ILog log, Session session)
        {
            _log = log;
            _session = session;
        }
        /// <summary>
        /// 异常测试
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        [AllowAnonymous, HttpPost]
        public UserLoginRes GetAbnormal(int num = 0)
        {
            throw new BusinessException($"微信错误");
        }


        /// <summary>
        /// 异常测试
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string GetUserId()
        {
            var user = _session.UserId;
            return user.ToString();
        }
    }
}
